var work={
	/*·····························初始化························*/
	init:function(){
		this.eventListen();
	},
	/*·····························事件监听························*/
	eventListen:function(){
		$(".telInfo").text(info.tel);
		// 创建工单
		$(document).on("click","#createOrder",function(){
			var url='/index.php?m=Service&c=Order&a=create&id='+info.id;
			var title="创建工单";
			work.layerOpen(title,url);
            
		});
		//编辑用户
		$(document).on("click","#customerEdit",function(){
			var url='/index.php?m=Service&c=Center&a=edit&id='+info.id+'&tel='+info.tel;
			var title="客户编辑";
			work.layerOpen(title,url);
		});
		// 切换用户
		$(document).on("click","#changeUser",function(){
			if(info.tel==undefined){
				info.tel='';
			}
			window.location.href="/index.php?m=Service&c=Center&a=choice&tel="+info.tel;
		});
		//搜索
		$(document).on("click","#search",function(){
			var tel=$("#searchTel").val();
			var name=$("#searchName").val();
			window.location.href='/index.php?m=Service&c=Center&a=choice&tel='+tel+'&name='+name;
		});
		// 查看所有工单
		$(document).on("click","#seeOrder",function(){
			var id=$(this).attr("uid");
			var title='查看所有工单';
			var url='/index.php?m=Service&c=Order&a=orderList&customerId='+id;
			work.layerOpenB(title,url);
		});
		// 查看工单
		$(document).on("click",".infoBtn",function(){
			var id=$(this).attr("uid");
			var title="工单详情";
			var url='/index.php?m=Service&c=Order&a=info&ID='+id;
			work.layerOpen(title,url);
		});
		// 创建用户
		$(document).on("click","#createCustomer",function(){
			$.post("/index.php?m=Admin&c=Customer&a=add",{tel:info.tel},function(data){
				if(data.stat==1){
					work.layerOpen('创建用户','/index.php?m=Service&c=Center&a=create&tel='+info.tel+'&customerId='+data.pk);
				}else{
					layer.msg(data.msg);
				}
			});
			
		});
		//查看用户更多信息
		$(document).on("click","#customerInfoBtn",function(){
			var id=$(this).attr("uid");
			var url='/index.php?m=Service&c=Center&a=getCustomer&id='+id;
			work.layerCap("用户详情",url);
		});
	},
	/*·····························功能性函数························*/
	// iframe页面弹窗
	layerOpen:function(title,url){
		layer.open({
			type: 2,
			area: ['800px', '600px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: title,
			content:url,
			cancel:function(){
				location.replace(location.href);
			}
		});
	},
	//大弹窗
	layerOpenB:function(title,url){
		layer.open({
			type: 2,
			area: ['980px', '600px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: title,
			content:url
		});
	},
		//创建用户
	layerCap:function(title,url){
		layer.open({
			type:2,
			shade: false,
		    title: title, //不显示标题
		    area: ['800px', '400px'],
		    content: url, //捕获的元素
		    cancel: function(index){
		        
		    }
		});
	}
}